<template>
	<view class="todobox">
		<block v-for="(item,index) in todoList" :key="index">
			<view class="item-box" :style="{'margin-top':(index==0?'0':'')}" @tap="clickCard(item)">
				<view class="todo-type">{{item.illustrate}}</view>
				<view class="applicant">{{item.applicant}}</view>
				<view class="applicant-time">发起时间:{{item.CREATE_TIME_}}</view>
			</view>
		</block>
	</view>
</template>

<script>
	import cardview from '@/components/uni-card/uni-card'
	import {apigetFielddata,apigetCostappById} from '@/common/api.js'
	export default {
		data() {
			return {
				todoList:[],
				year:'',
				month:'',
				days:'',
				day:''
			}
		},
		components:{
			"card-view":cardview,
		},
		onLoad(e){
			this.todoList=JSON.parse(e.todoList)
			this.todoList.forEach(item=>{item.CREATE_TIME_=this.change_time(item.CREATE_TIME_)})
		},
		methods: {
			change_time(time){
				let date=new Date(time)
				let year=date.getFullYear()
				let month=date.getMonth()+1
				let days=date.getDate()
				let hour=date.getHours()
				let min=date.getMinutes()
				let second=date.getSeconds()
				return year+'年'+month+'月'+days+'日 '+hour+':'+min+':'+second
			},
			clickCard(item){	
				let KEY=item.BUSINESS_KEY_.split('.')[0]
				
				console.log(KEY)
				switch(KEY){
					case 'findFieldpView':
					uni.navigateTo({
						url: '/pages/index/todo/Apply-go-out?active='+JSON.stringify(item)
					});
					break
					case 'costappView':
					uni.navigateTo({
						url: '/pages/index/todo/Apply-cost?active='+JSON.stringify(item)
					});
					// apigetCostappById({costapp_id:id}).then(res=>{
					// 	console.log(res)
					// 	uni.navigateTo({
					// 		url: '/pages/index/todo/Apply-cost?content='+JSON.stringify(res.data)+"&active="+JSON.stringify(item)
					// 	});
					// })
					break
					default:
					uni.showToast({
						title: '外勤以外的流程暂时没开通办理',
						mask: true,
						icon:'none',
						duration: 1000
					})
					break;
					
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.todobox{
		padding: 30upx;
	}
	.item-box{
		padding: 2%;
		// border:1upx solid #B2B2B2;
		border-radius: $uni-border-radius-base;
		width: 96%;
		height: 140upx;
		margin-top: 20upx;
		background: #FFFFFF;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)
	}
	.item-box:active{
		box-shadow:none;
		box-shadow:2upx 2upx 5upx #B5B5B5 inset;
		border: #FFFFFF 1upx solid;
	}
	.todo-type{
		width: 80%;
		height: 70upx;
		line-height: 70upx;
		float: left;
		overflow:hidden;
	}
	.applicant{
		width: 20%;
		text-align: right;
		height: 70upx;
		line-height: 70upx;
		float: left;
	}
	.applicant-time{
		border-bottom: 1upx solid #d2d2d2;
		font-size: 20upx;
		color: #a5a5a5;
		width: 100%;
		height: 70upx;
		line-height: 70upx;
	}
</style>
